package com.robot.mvvm.ui.splash

import android.annotation.SuppressLint
import android.os.Bundle
import android.text.TextUtils
import com.robot.mvvm.R
import com.robot.mvvm.databinding.AppActivitySplashBinding
import com.robot.mvvm.vm.splash.SplashViewModel
import com.robot.base.base.activity.GLBaseActivity
import com.robot.base.configs.AppConstants
import com.robot.base.configs.PrefsManager
import com.robot.base.util.arouter.ARouterUtil
import me.goldze.mvvmhabit.BR

/**
 * 启动页
 */
@SuppressLint("CustomSplashScreen")
class SplashActivity : GLBaseActivity<AppActivitySplashBinding, SplashViewModel>() {

    override fun initContentView(savedInstanceState: Bundle?): Int = R.layout.app_activity_splash

    override fun initVariableId(): Int = BR.viewModel

    override fun initComponents() {
        val token = PrefsManager.getUserLoginInfo().token
        if(TextUtils.isEmpty(token)){
            ARouterUtil.goToActivity(AppConstants.Router.Main.A_LOGIN)
        }else{
            ARouterUtil.goToActivity(AppConstants.Router.Main.A_MAIN)
        }
        finish()
    }

}